/**
 * 下导航
 */
$(document).ready(
    function () {

        /**
         * 获取项目根路径
         *
         * @returns {string} 返回路径地址
         */
        function getRootPath() {
            //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
            var curWwwPath = window.document.location.href;
            //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
            var pathName = window.document.location.pathname;
            var pos = curWwwPath.indexOf(pathName);
            //获取主机地址，如： http://localhost:8083
            var localhostPaht = curWwwPath.substring(0, pos);
            //获取带"/"的项目名，如：/uimcardprj
            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
            return (localhostPaht + projectName);
        }

        /**
         * 截取url
         * @returns {Object}
         * @constructor
         */
        function GetRequest() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }


        var Request = new Object();
        Request = GetRequest();

        //方法
        function navigation(thisClick, classId) {
            $.ajax({
                type: "POST",
                async: false,
                url: getRootPath() + "/N.do",
                data: "nName=" + thisClick,
                success: function (data) {
                    //清空
                    $(classId).empty();
                    $.each(data.data, function (key, clickLink) {
                        $(classId).append('<li><a href=' + clickLink.clickPath + '>' + clickLink.titleName + '</a></li>');
                    });

                }
            });
        }

        //电视
        $("#tvN").click(function () {
            navigation('电视', '#tvN div ul');
        });

        //智慧生活
        $("#lifeN").click(function () {
            navigation('智慧生活', "#lifeN div ul");
        });

        //技术运营
        $("#operN").click(function () {
            navigation('技术运营', "#operN div ul");
        });

        //版权合作
        $("#copyN").click(function () {
            navigation('版权合作', "#copyN div ul");
        });

        //联系我们
        $("#tellN").click(function () {
            navigation('联系我们', "#tellN div ul");
        });

        //内容获取
        var curWwwPath = window.document.location.href;
        if (curWwwPath.indexOf("/adv.html") > 0) {
            $.ajax({
                type: "POST",
                async: false,
                url: getRootPath() + "/Q.do",
                data: "conId=" + Request["conId"],
                success: function (data) {
                    $("#titleNameP").text('> '+data.data.titleName);
                    $("#titleNameP").after(data.data.detailed);
                }
            });

        }

    });